package com.ruoyi.web.controller.material;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.material.domain.SysUserMaterial;
import com.ruoyi.material.service.ISysUserMaterialService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 资料评分Controller
 * 
 * @author hsx
 * @date 2022-01-09
 */
@RestController
@RequestMapping("/material/mark")
public class SysUserMaterialController extends BaseController
{
    @Autowired
    private ISysUserMaterialService sysUserMaterialService;

    /**
     * 查询资料评分列表
     */
    @PreAuthorize("@ss.hasPermi('material:mark:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysUserMaterial sysUserMaterial)
    {
        startPage();
        List<SysUserMaterial> list = sysUserMaterialService.selectSysUserMaterialList(sysUserMaterial);
        return getDataTable(list);
    }

    /**
     * 导出资料评分列表
     */
    @PreAuthorize("@ss.hasPermi('material:mark:export')")
    @Log(title = "资料评分", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysUserMaterial sysUserMaterial)
    {
        List<SysUserMaterial> list = sysUserMaterialService.selectSysUserMaterialList(sysUserMaterial);
        ExcelUtil<SysUserMaterial> util = new ExcelUtil<SysUserMaterial>(SysUserMaterial.class);
        util.exportExcel(response, list, "资料评分数据");
    }

    /**
     * 获取资料评分详细信息
     */
    @PreAuthorize("@ss.hasPermi('material:mark:query')")
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId)
    {
       // return AjaxResult.success(sysUserMaterialService.selectSysUserMaterialByUserId(userId));
        return null;
    }

    /**
     * 修改资料评分
     */
    @PreAuthorize("@ss.hasPermi('material:mark:edit')")
    @Log(title = "资料评分", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysUserMaterial sysUserMaterial)
    {
        return toAjax(sysUserMaterialService.updateSysUserMaterial(sysUserMaterial));
    }
}
